package structuralModel.flyWeightModel;

public class FlyWeightClient {

    public static void main(String[] args){
        FlyWeightFactory flyWeightFactory = new FlyWeightFactory();
        WebSite weChatWebSite = flyWeightFactory.getWebSite("微信");
        weChatWebSite.use(new User("zs"));

        WebSite weiboWebSite = flyWeightFactory.getWebSite("微博");
        weiboWebSite.use(new User("lisi"));

        WebSite webSite2 = flyWeightFactory.getWebSite("网页");
        webSite2.use(new User("wangwu"));

        WebSite webSite3 = flyWeightFactory.getWebSite("公众号");
        webSite3.use(new User("zs1"));

        flyWeightFactory.getWebSite("网页").use(new User("zs2"));
        flyWeightFactory.getWebSite("公众号").use(new User("zs3"));
        flyWeightFactory.getWebSite("公众号").use(new User("zs4"));
        // 只创建了4个对象, 所以在这里打印出来的结果是4 ; 这是享元模式的核心
        System.out.println(flyWeightFactory.getWebSiteCount());
        Integer a  = null;
    }
}
